<ix-modal-header
  [requiredRoles]="requiredRoles"
  [title]="'Cloud Credentials' | translate"
  [loading]="isLoading()"
></ix-modal-header>

<mat-card>
  <mat-card-content>
    <form class="ix-form-container" (submit)="onSubmit()">
      <ix-fieldset [title]="'Name and Provider' | translate" [formGroup]="commonForm">
        <ix-select
          formControlName="type"
          [label]="'Provider' | translate"
          [required]="true"
          [options]="providerOptions"
          [tooltip]="helptext.provider.tooltip | translate"
        ></ix-select>

        @if (showProviderDescription) {
          <ix-cloudsync-provider-description
            [provider]="commonForm.controls.type.value"
          ></ix-cloudsync-provider-description>
        }

        <ix-input
          formControlName="name"
          [label]="'Name' | translate"
          [required]="true"
        ></ix-input>
      </ix-fieldset>

      <ng-container #providerFormContainer></ng-container>

      <ix-form-actions>
        <button
          *ixRequiresRoles="requiredRoles"
          mat-button
          type="submit"
          color="primary"
          ixTest="save"
          [disabled]="areActionsDisabled"
        >
          {{ 'Save' | translate }}
        </button>
        <button
          *ixRequiresRoles="requiredRoles"
          mat-button
          type="button"
          ixTest="verify-credential"
          [disabled]="areActionsDisabled"
          (click)="onVerify()"
        >
          {{ 'Verify Credential' | translate }}
        </button>
      </ix-form-actions>
    </form>
  </mat-card-content>
</mat-card>
